package com.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.project.entity.LogCount;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * ClassName: LogCountMapper
 * Package: com.project.mapper
 * Description:
 *
 * @Author 看到风
 * @Create 2023/10/31 22:15
 * @Version 1.0
 */
@Mapper
public interface LogCountMapper extends BaseMapper<LogCount> {
    @Select("select max(count) from log_count where project_id=#{projectId}")
    public int getLogCount (Long projectId);

    @Select("select * from log_count where count= (select max(count) from log_count where project_id=#{projectId}) and project_id=#{projectId}")
    public LogCount getLog(Long projectId);

    //删除所有日志
    @Delete("delete  from log_count where project_id=#{projectId} ")
    public void delete(Long projectId);

    //插入一条
    @Insert("insert into log_count (id,project_id,is_pass,error_msg,count) values (null,#{projectId},null,null,#{count})")
    public void insertOne(Long projectId,int count );

}
